package edu.pitt.dbmi.odie.gapp.gwt.client.util.picker.pastel;

import com.smartgwt.client.data.DataSource;
import com.smartgwt.client.data.DataSourceField;
import com.smartgwt.client.types.FieldType;

public class ODIE_PastelDS extends DataSource {

	private static ODIE_PastelDS instance = null;
	
	private static final int NUM_COLS = 7 ;

	public static ODIE_PastelDS getInstance() {
		if (instance == null) {
			instance = new ODIE_PastelDS("ODIE_PastelDS");
		}
		return instance;
	}

	public ODIE_PastelDS(String id) {
		setShowPrompt(false) ;
		fillDataSourceFields(id) ;
	}

	public void fillDataSourceFields(String id) {
		setID(id);
		setRecordXPath("/pastelTable/pastelRow");
		DataSourceField[] fields = new DataSourceField[NUM_COLS];
		for (int idx = 0; idx < NUM_COLS; idx++) {
			String xpathIdx = idx + 1 + "";
			fields[idx] = new DataSourceField("pastel-" + xpathIdx,
					FieldType.TEXT, idx + "");
			fields[idx].setLength(7) ;
			addField(fields[idx]);
		}
		setDataURL("data/dataIntegration/xml/pastels.xml");
	}

}